package com.pet.shop.service.pet;

import com.github.pagehelper.Page;
import com.pet.shop.dto.PageDto;
import com.pet.shop.entity.shop.PetInjection;
import com.pet.shop.mappers.shop.PetInjectionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PetInjectionServiceImpl implements IPetInjectionService {

    @Autowired
    private PetInjectionMapper petInjectionMapper;

    @Override
    public int deleteEntity(Long id) {
        return petInjectionMapper.delete(id);
    }

    @Override
    public int deleteEntityList(List<Long> idList) {
        if(idList == null || idList.isEmpty()) return 0;
        int i = 0;
        for (Long id : idList) {
            i += petInjectionMapper.delete(id);
        }
        return i;
    }

    @Override
    public PetInjection insertEntity(PetInjection record) {
        petInjectionMapper.insert(record);
        return record;
    }

    @Override
    public PetInjection getEntity(Long id) {
        return petInjectionMapper.get(id);
    }

    @Override
    public int updateEntity(PetInjection record) {
        return petInjectionMapper.update(record);
    }

    @Override
    public PageDto<PetInjection> queryPage(PageDto<PetInjection> pageDto) {
        Page<PetInjection> page = petInjectionMapper.queryPage(pageDto);
        pageDto.setPageResult(page);
        return pageDto;
    }
}
